// 课程模块接口集合
import request from './request.js'

/**
 * 课程分页查询
 */
export const getCoursesPage = (data) => {
	return request.post('/courses/page', data)
}

/**
 * 修改课程
 */
export const updateCourses = (data) => {
	return request.put('/courses', data)
}

/**
 * 上传课程图片
 */
export const uploadCoursesImages = (data) => {
	return request.post('/courses/image', data, {
		headers: {
			'Content-Type': 'multipart/form-data'
		}
	})
}

/**
 * 删除图片
 */
export const deleteImage = (id) => {
	return request.delete(`/courses/image/${id}`)
}

/**
 * 批量删除课程
 */
export const deleteListCourses = (data) => {
	return request.delete('/courses', {
		data
	})
}

/**
 * 创建课程
 */
export const insertCourses = (data) => {
	return request.post('/courses', data)
}

/**
 * 获取课程详情
 */
export const getCourseDetail = (id) => {
	return request.get(`/courses/${id}`)
}

/**
 * 上传课程图片（适配后端接口）
 * @param {File[]} files - 要上传的文件列表
 */
export const uploadCourseImage = (formData) => {
  return request.post(`/courses/image`, formData, {
    headers: {
      'Content-Type': 'multipart/form-data', // 必须设置
    },
  });
};